package com.cgbl.cg.ui.mine

import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import com.cgbl.cg.BR
import com.cgbl.cg.R
import com.cgbl.cg.adapter.CourseProfileCommentAdapter
import com.cgbl.cg.adapter.CourseProfileDirectoryAdapter
import com.cgbl.cg.adapter.CourseProfileResourceAdapter
import com.cgbl.cg.databinding.AppFragmentCourseCommentBinding
import com.cgbl.cg.databinding.AppFragmentCourseDirectoryBinding
import com.cgbl.cg.databinding.AppFragmentCourseProfileBinding
import com.cgbl.cg.databinding.AppFragmentCourseResourceBinding
import com.cgbl.cg.view.ExchangeCodePop
import com.cgbl.cg.view.PersonalSignPop
import com.cgbl.cg.vm.mine.CourseProfileViewModel
import com.cgbl.cg.vm.mine.ResourceFileViewModel
import com.lxj.xpopup.XPopup
import com.robot.base.base.activity.GLBaseFragment
import com.robot.base.model.CourseInfoFileBean
import com.robot.base.model.ResourceDetailBean

class CourseResourceFragment :
    GLBaseFragment<AppFragmentCourseResourceBinding, ResourceFileViewModel>() {

    private lateinit var courseProfileResourceAdapter: CourseProfileResourceAdapter

    override fun initContentView(
        inflater: LayoutInflater?,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): Int = R.layout.app_fragment_course_resource

    override fun initVariableId(): Int = BR.viewModel

    override fun initComponents() {
        courseProfileResourceAdapter = CourseProfileResourceAdapter()
        binding.recyclerView.apply {
            layoutManager = LinearLayoutManager(context)
            adapter = courseProfileResourceAdapter
        }
    }

    fun setCourseProfileData(
        list: MutableList<CourseInfoFileBean>?,
        pay: String?,
        id: String?,
        type: String
    ) {
        viewModel.pay.set(pay == "1")
        viewModel.productId = id ?: ""
        viewModel.payType = type
        courseProfileResourceAdapter.setNewInstance(list)
    }
}